package com.fallsvc.re.javase;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

/**
 * @auther falls_vc
 * description:
 * @date 2025/10/10  9:11
 */
public class Demo1 {
    public static void main1(String[] args) {
//        int a;
//        a = 10;
//        System.out.println(a);

//        byte b = 1;
//        System.out.println(b+2 );

        String str = "100";
        Integer a = Integer.valueOf(str);
        Integer b = Integer.parseInt(str);
        System.out.println(a);
        System.out.println(b);
    }

    public static void main2(String[] args) {
//        int a = 1;
//        System.out.println(~a);

//        int a = -3;
//        System.out.println(a >> 1);
//        System.out.println(a >>> 1);

        int a = 2;
        System.out.println(a>>1);
        System.out.println(a<<2);
    }

    public static void main3(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        int sum = 0;
//        while (scanner.hasNextInt()) {
//            sum += scanner.nextInt();
//            // ctrl D 结束
//        }
//        System.out.println(sum);

        Random random = new Random();
        int a = random.nextInt(0, 10);
        System.out.println(a);
    }

    public static void swap(Integer x,Integer y) {
//
        Integer tmp = x;
        x = y;
        y = tmp;
        return ;
    }
    public static void change(Integer x) {
        x *= 3;
    }
    public static void main4(String[] args) {
        Integer a = 10;
        Integer b = 20;
        swap(a,b);// 无法交换
        System.out.println(a);
        System.out.println(b);
        change(a);
        System.out.println(a);
    }
    public static int fib(int n) {
        if(n == 1 || n == 2)
            return 1;
        return fib(n-1) + fib(n-2);
    }

    public static void main5(String[] args) {
        System.out.println(fib(5));
    }

    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
        int[] newA = Arrays.copyOf(arr,arr.length);
        int[] newB= Arrays.copyOfRange(arr,1,3);
       printArr(newA);
       printArr(newB);
    }

    private static void printArr(int[] arr) {
        for (int x : arr) {
            System.out.println(x);
        }
    }
}
